<?php
declare(strict_types=1);

use Phinx\Migration\AbstractMigration;

final class AddColumnTaskRelationInTable extends AbstractMigration
{
    public function up()
    {
        $this->table("task_relation")
            ->addColumn('source_step_category_id', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '下游环节'])
            ->addColumn('target_step_category_id', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '上游环节'])
            ->addColumn('project_id', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '项目ID'])
            ->addColumn('relation', 'string', ['limit' => 45, 'default' => '', 'comment' => '上游关系:开始(start),交付(delivery),关联(relation)'])
            ->save();
    }

    public function down()
    {
        $this->table('task_relation')
            ->removeColumn('relation')
            ->removeColumn('source_task_id')
            ->removeColumn('target_task_id')
            ->removeColumn('source_step_category_id')
            ->removeColumn('target_step_category_id')
            ->save();
    }
}
